package club.emergency.wechat.ranking.operate.consumer.controller;

import club.emergency.wechat.common.response.ResponseEntity;
import club.emergency.wechat.common.utils.JsonConvert;
import club.emergency.wechat.ranking.operate.consumer.service.RankingOperateConsumer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Create with IntelliJ IDEA
 * Project Name: wechat
 * Package Name: club.emergency.wechat.ranking.operate.consumer.controller
 * Date: 2019/2/25
 *
 * @author: 快乐的小菌菌
 * Description:
 */
@Api("排行榜操作接口")
@RestController
@RequestMapping("/ranking-operate")
public class RankingOperateController {

    private RankingOperateConsumer rankingOperateConsumer;

    public RankingOperateController(RankingOperateConsumer rankingOperateConsumer) {
        this.rankingOperateConsumer = rankingOperateConsumer;
    }

    @ApiOperation("分数增量")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "staffId", value = "人员id", dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "score", value = "分数", dataType = "long", paramType = "query"),
    })
    @PostMapping("/addAndIncrementScore")
    public ResponseEntity addAndIncrementScore(
            @RequestParam("staffId") Long staffId,
            @RequestParam("score") Integer score
    ) {
        return new JsonConvert<ResponseEntity>().jsonDecode(rankingOperateConsumer.incrementScore(staffId, score), ResponseEntity.class);
    }
}
